package com.fbinggun.fattribute.attribute.attack;

import com.fbinggun.fattribute.FAttributePlugin;
import com.fbinggun.fattribute.attribute.AAttack;
import com.fbinggun.fattribute.effect.ContinuousEffect;
import com.fbinggun.fattribute.effect.IEffect;
import com.fbinggun.fattribute.data.EntityData;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

import java.util.Map;


public class Continuous extends AAttack {
    @Override
    public double getDamage(EntityData data, EntityDamageByEntityEvent event){
       Map<IEffect,Integer> map =data.getiEffects();
       if(map!=null&&map.size()!=0){
           for(IEffect effect: map.keySet()){
               if(effect instanceof ContinuousEffect){
                   ContinuousEffect continuousEffect= (ContinuousEffect) effect;
                   double d = getValue(data)*Math.min(continuousEffect.getModification(),5);
                   continuousEffect.setModification(continuousEffect.getModification()+1);
                   continuousEffect.setDuration(100);
                   data.iEffects.put(effect,100);
                   return d;
               }
           }
       }
           data.addEffect(new ContinuousEffect(1,data));
           return getValue(data);
    }

    @Override
    public String getID() {
        return "Continuous";
    }

    @Override
    public String getKey() {
        return FAttributePlugin.plugin.getConfigKey("Continuous");
    }

    @Override
    public int getCombat() {
        return 0;
    }
}
